<template>
	<view>
		<view class="topBox">
			<view class="imgbox" @click="upImg">
				<image :src="img" mode="aspectFill" v-if="img!=null" ></image>
				<view v-else>点击上传付款截图</view>
			</view>
			<view class="imgbox">
				<image src="../../static/user/zju.jpg" mode="aspectFill" @click="lookImg('../../static/user/zju.jpg')" v-if="type==1"></image>
				<image src="../../static/user/bankzz.jpg" mode="aspectFill" @click="lookImg('../../static/user/bankzz.jpg')" v-if="type==0"></image>
			</view>
		</view>
		<view class="box" v-if="type==0">
			<view class="title">转账信息</view>
			<view class="item">
				<view class="item-l">
					<view class="it-t">持卡行</view>
					<view class="it-con">{{bankname}}</view>
				</view>
				<view class="item-r" @click="copy(bankname)">复制</view>
			</view>
			<view class="item">
				<view class="item-l">
					<view class="it-t">卡号</view>
					<view class="it-con">{{account}}</view>
				</view>
				<view class="item-r" @click="copy(account)">复制</view>
			</view>
			<view class="item">
				<view class="item-l">
					<view class="it-t">姓名</view>
					<view class="it-con">{{name}}</view>
				</view>
				<view class="item-r" @click="copy(name)">复制</view>
			</view>
			<view class="item">
				<view class="item-l">
					<view class="it-t">金额</view>
					<view class="it-con">{{money}}</view>
				</view>
				<view class="item-r" @click="copy(money)">复制</view>
			</view>
			<view class="item">
				<view class="item-l">
					<view class="it-t">VS手机号</view>
					<view class="it-con">{{phone}}</view>
				</view>
				<view class="item-r" @click="copy(phone)">复制</view>
			</view>
		</view>
		<view class="box" v-if="type==1">
			<view class="title">转账信息</view>
			<view class="item">
				<view class="item-l">
					<view class="it-t">支付宝账号</view>
					<view class="it-con">{{account}}</view>
				</view>
				<view class="item-r" @click="copy(account)">复制</view>
			</view>
			<view class="item">
				<view class="item-l">
					<view class="it-t">支付宝姓名</view>
					<view class="it-con">{{name}}</view>
				</view>
				<view class="item-r" @click="copy(name)">复制</view>
			</view>
			<view class="item">
				<view class="item-l">
					<view class="it-t">金额</view>
					<view class="it-con">{{money}}</view>
				</view>
				<view class="item-r" @click="copy(money)">复制</view>
			</view>
			<view class="item">
				<view class="item-l">
					<view class="it-t">VS手机号</view>
					<view class="it-con">{{phone}}</view>
				</view>
				<view class="item-r" @click="copy(phone)">复制</view>
			</view>
		</view>
		<view style="text-align: center;margin-top: 30rpx;">
			将VS手机号填写到转账备注里面
		</view>
		<view class="btn" @click="submit" v-if="tijiao">
			确认提交
		</view>
		<view class="btn1" v-else>
			确认提交
		</view>
	</view>
</template>
<script>
	import uniCopy from '@/js_sdk/uni-copy.js';
	import {getAlipayAccount,getBankCardNumber,transferRecharge} from '../../api/user.js'
	export default {
		components: {},
		data() {
			return {
				img:null,
				type:null,//0 银行卡支付 1 支付宝
				money:null,
				phone:null,
				name:null,
				account:null,
				bankname:null,
				tijiao:true
				
			};
		},
		// 
		onLoad(e) {
			this.type=e.type
			this.money=e.money
			this.phone=uni.getStorageSync('userInfo').phone
			if(this.type==1){
				this.getAlipay()
			}else{
				this.getBank()
			}
			
			
		},
		onShow() {},

		//下拉刷新
		onPullDownRefresh() {},
		methods: {
			upImg(){
				this.upimgs((res)=>{
					console.log(res)
					this.img=res
				},1)
			},
			async submit(){
				if(this.img==null){
					this.msg("未上传截图","none")
				}else{
					this.post(transferRecharge,{
						img:this.img,
						type:this.type,
						name:this.name,
						account:this.account,
						money:this.money,
						phone:this.phone,
						openingBank:this.bankname
					}).then(it=>{
						console.log(it)
						this.msg('提交成功，请等待审核','none')
						this.tijiao=false
						setTimeout(()=>{
							uni.navigateBack({
								delta:1
							})
						},1500)
						
					})
					
				}
			},
			async getAlipay(){
				this.get(getAlipayAccount).then(res=>{
					console.log(res)
					this.name=res.data.name
					this.account=res.data.account
				})
			},
			async getBank(){
				this.get(getBankCardNumber).then(r=>{
					console.log(r)
					this.account=r.data.account
					this.name=r.data.name
					this.bankname=r.data.bank_name
				})
			},
			lookImg(url){
				let arr=[url]
				console.log(arr)
				uni.previewImage({
					current:url,
					urls: arr
				});
			},
			copy(e) {
				uniCopy({
					content: e,
					success: (res) => {
						uni.showToast({
							title: '复制成功',
							icon: 'none',
							duration: 2000,
						})
					},
					error: (e) => {
						uni.showToast({
							title: e,
							icon: 'none',
							duration: 3000,
						})
					}
				})
			},
		}
	}
</script>
<style scoped>
	.btn1{
		width: 460rpx;
		height: 88rpx;
		background: #F0812D;
		opacity: 0.3;
		border-radius: 8rpx;
		text-align: center;
		line-height: 88rpx;
		margin-top: 100rpx;
		margin-left: 145rpx;
		color: #FFFFFF;
		font-size: 34rpx;
	}
	.btn{
		width: 460rpx;
		height: 88rpx;
		background: #F0812D;
		opacity: 1;
		border-radius: 8rpx;
		text-align: center;
		line-height: 88rpx;
		margin-top: 100rpx;
		margin-left: 145rpx;
		color: #FFFFFF;
		font-size: 34rpx;
	}
	.it-con{
		font-size: 30rpx;
		font-family: .PingFang SC;
		font-weight: 400;
		line-height: 42rpx;
		color: #333333;
		opacity: 1;

	}
	.it-t{
		width: 200rpx;
		font-size: 30rpx;
		font-family: .PingFang SC;
		font-weight: 300;
		line-height: 42rpx;
		color: #666666;
		opacity: 1;

	}
	.item-r{
		width: 78rpx;
		height: 44rpx;
		background: #F0812D;
		opacity: 1;
		border-radius: 4rpx;
		text-align: center;
		line-height: 44rpx;
		color: #FFFFFF;
		font-size: 24rpx;

	}
	.item{
		display: flex;
		align-items: center;
		margin-top: 40rpx;
		justify-content: space-between;
		
	}
	.item-l{
		display: flex;
		align-items: center;
		width: 580rpx;
		border-bottom: 1px #D7D7D7 solid;
		padding-bottom: 10rpx;
	}
	.title{
		font-size: 32rpx;
		font-family: .PingFang SC;
		font-weight: 400;
		line-height: 45rpx;
		color: #333333;
		opacity: 1;

	}
	.box{
		padding: 40rpx 30rpx 0;
		box-sizing: border-box;
	}
	.topBox{
		display: flex;
		align-items: center;
		justify-content: space-around;
		margin-top: 60rpx;
		padding: 0 60rpx;
		box-sizing: border-box;
	}
	.imgbox{
		width: 246rpx;
		height: 268rpx;
		border: 1px solid #707070;
		border-radius: 8rpx;
		display: flex;
		justify-content: center;
		align-items: center;
		overflow: hidden;
	}
	.imgbox>image{
		width: 100%;
		height: 100%;
	}
</style>
